<template>
  <div>{{ node.nodeName }}</div>
</template>

<script setup name="startEventNode">
import { inject } from "vue";
import { KEY_VALIDATOR } from "../flow";

const props = defineProps({
  tempNodeId: {
    // 临时节点ID
    type: String
  },
  node: {
    // 传入的流程配置数据
    type: Object,
    default: () => {}
  }
});
// 获取流程验证器实例
const validator = inject(KEY_VALIDATOR);

// 注册验证器
validator.register(props.tempNodeId, () => {
  if (!props.node.nodeName) {
    return {
      valid: false,
      message: "请输入节点名称"
    };
  }
  if (!props.node.pageId) {
    return {
      valid: false,
      message: "请选择在线页面"
    };
  }
  return {
    valid: true
  };
});
</script>

<style lang="scss" scoped></style>
